/*******************************************************************************
 * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
 * Distributed under license by Red Hat, Inc. All rights reserved.
 * This program is made available under the terms of the
 * Eclipse Public License v1.0 which accompanies this distribution,
 * and is available at http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Exadel, Inc. and Red Hat, Inc. - initial API and implementation
 ******************************************************************************/ 
package demo;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.List;

import javax.ejb.EJB;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.jboss.soa.tareas.ObtieneTareasDeRolFault1;
import org.jboss.soa.tareas.ObtieneTareasDeRolPortType;
import org.jboss.soa.tareas.ObtieneTareasDeRolService;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

import cl.gob.ips.offline.jbpm.JBPMBean;
import cl.gob.ips.offline.jbpm.JBPMBeanRemote;
import cl.gob.ips.offline.util.Tarea;

import demo.dao.JBPMDao;

import demo.util.ParseaSalida;

public class ValidacionSolicitudAction extends org.apache.struts.action.Action {

	@EJB
    JBPMBeanRemote beanRemote = new JBPMBean(); 
    public ValidacionSolicitudAction() {
    }

    public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {

      System.out.println("AnalisisSolicitudAction");
      IngresarSolicitudForm formulario = (IngresarSolicitudForm) form;
      
      //JBPMDao dao = new JBPMDao();
      List<Tarea> tareas = beanRemote.getAssignedTasks("analista","validacion");
      //List<Tarea> tareas = dao.traerTareasPorRol("analista",formulario.getTipo());
     
     if(tareas.size()==1 && tareas.get(0).getId().equals("0")){
    	 request.setAttribute("vacio", tareas.get(0).getDescripcion());
     }
     request.setAttribute("tareas", tareas);
		
		
     
     return mapping.findForward("success");
    }
 
    
}